package org.mech.sefer.server.service.bible;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.mech.sefer.entity.bible.converter.TBibleConverter;
import org.mech.sefer.entity.bible.dao.BibleDao;
import org.mech.sefer.entity.converter.ConversionException;
import org.mech.sefer.model.bible.TBible;
import org.mech.sefer.service.ServiceException;
import org.mech.sefer.service.bible.BibleService;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = true)
public class BibleServiceImpl implements BibleService {

	@Resource(name = "bibleDao")
	private BibleDao bibleDao;

	@Resource(name = "tBibleConverter")
	private TBibleConverter tBibleConverter;

	@Override
	public List<TBible> loadAll() throws ServiceException {
		try {
			return new ArrayList<TBible>(tBibleConverter.convertAll(bibleDao.findAll()));
		} catch (ConversionException e) {
			throw new ServiceException(e);
		}
	}

}
